#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_one_class_dog.py
# author:张世航
# datetime:2024/11/12 23:39
# software: PyCharm
"""
随堂练习:
 定义一个dog类(颜色, 名称), 里面有一个狗叫的方法; 不同的狗叫声可能不一样(打打印提示语句, XXX狗在叫,来体现叫声不一样);
 然后实例化几条狗, 然后统计实例化狗的数量;
"""
# import module your need

class Dog:
    def __init__(self, color, name):
        self.color = color
        self.name = name

    def bark(self):
        if self.color == 'black':
            print(f"{self.name} 狗在汪汪叫！")
        elif self.color == 'white':
            print(f"{self.name} 狗在嗷嗷叫！")
        else:
            print(f"{self.name} 狗在叫！")

# 实例化几条狗
dogs = []
dogs.append(Dog('black', '小黑'))
dogs.append(Dog('white', '小白'))
dogs.append(Dog('brown', '小棕'))

# 统计实例化狗的数量
dog_count = len(dogs)
print(f"总共有 {dog_count} 条狗。")

# 让每条狗叫一声
for dog in dogs:
    dog.bark()